package com.dongpl.advice;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.ModelAndView;

/**
 * 异常过滤配置类
 */
@Slf4j
@RestControllerAdvice
public class ShiroException {

    /**
     * 权限异常
     */
    @ExceptionHandler(AuthorizationException.class)
    public String authorizationException (){
        return "抱歉您没有权限访问该内容!";
    }

    /**
     * 原理AOP，捕获全局异常
     */
    /*@ExceptionHandler(value = Exception.class)
    private ModelAndView exHandler(Exception ex) {
        ModelAndView mav = new ModelAndView("error");
        mav.addObject("msg", ex.getMessage());
        return mav;
    }*/

}
